#include <stdlib.h>
#include <stdio.h>
#include <memory.h>

#if WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif  // WIN32

#if OSX
#include <CoreServices/CoreServices.h>
#endif  // OSX

#include <algorithm>
#include "common.h"
#include "logging.h"

//////////////////////////////////////////////////////////////////////
// Assertions
//////////////////////////////////////////////////////////////////////

namespace base {

void Break() {
#if WIN32
	::DebugBreak();
#elif OSX  // !WIN32
	__asm__("int $3");
#else // !OSX && !WIN32
	#if _DEBUG_HAVE_BACKTRACE
	OutputTrace();
	#endif
	abort();
#endif // !OSX && !WIN32
}

void LogAssert(const char * function, const char * file, int line, 
	const char * expression)
{
	// TODO - if we put hooks in here, we can do a lot fancier logging
	LOG(LS_ERROR) << file << "(" << line << ")" << ": ASSERT FAILED: "
		<< expression << " @ " << function;
}

} // namespace base
